﻿using System;
using System.Data;
using System.Collections.Generic;
using Maticsoft.Common;
using lcps.Model;
namespace lcps.BLL
{
	/// <summary>
	/// projectinfo
	/// </summary>
	public partial class projectinfo
	{
		private readonly lcps.DAL.projectinfo dal=new lcps.DAL.projectinfo();
		public projectinfo()
		{}
        #region  Method
        public bool Isup(int id)
        {
            return dal.Isup(id);
        }
        public bool setIsup(int id)
        {
            return dal.setIsup(id);
        }
        public bool setstatusList(string IDlist, string sta)
        {
            return dal.setstatusList(IDlist, sta);
        }
        public bool setbzList(string IDlist, string sta)
        {
            return dal.setbzList(IDlist, sta);
        }
        public bool setcoordinateList(string IDlist, string sta)
        {
            return dal.setcoordinateList(IDlist, sta);
        }
        public bool setreceivednameList(string IDlist, string sta)
        {
            return dal.setreceivednameList(IDlist, sta);
        }
        public bool setrealtimeList(string IDlist, string sta)
        {
            return dal.setrealtimeList(IDlist, sta);
        }
        public bool setplanarrivedateList(string IDlist, string sta)
        {
            return dal.setplanarrivedateList(IDlist, sta);
        }
        //办理出入库时间 
        public bool setdealStorageDate(string IDlist, string sta)
        {
            return dal.setdealStorageDate(IDlist, sta);
        }
        //确定交货期
        public bool setconfirmdate(string IDlist, string sta)
        {
            return dal.setconfirmdate(IDlist, sta);
        }
         //是否预警
        public bool setIsWarn(string IDlist, string sta)
        {
            return dal.setIsWarn(IDlist, sta);
        }
        /// <summary>
        /// 得到最大ID
        /// </summary>
        public int GetMaxId()
        {
            return dal.GetMaxId();
        }

        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int ID)
        {
            return dal.Exists(ID);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(lcps.Model.projectinfo model)
        {
            //if (!dal.Exists(model))
                return dal.Add(model);
            //else
            //    return false;
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// 
        /// 
        public bool UpdateGV(lcps.Model.projectinfo model)
        {
            return dal.UpdateGV(model);
        }
        public bool Update(lcps.Model.projectinfo model)
        {
            return dal.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int ID)
        {

            return dal.Delete(ID);
        }


        /// <summary>
        /// 批量删除数据根据条件 ，条件为空全表删除！
        /// </summary>
        public bool DeleteByWhere(string where)
        {
            return dal.DeleteByWhere(where);
        }
        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool DeleteList(string IDlist)
        {
            return dal.DeleteList(IDlist);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public lcps.Model.projectinfo GetModel(int ID)
        {

            return dal.GetModel(ID);
        }

        /// <summary>
        /// 得到一个对象实体，从缓存中
        /// </summary>
        public lcps.Model.projectinfo GetModelByCache(int ID)
        {

            string CacheKey = "projectinfoModel-" + ID;
            object objModel = Maticsoft.Common.DataCache.GetCache(CacheKey);
            if (objModel == null)
            {
                try
                {
                    objModel = dal.GetModel(ID);
                    if (objModel != null)
                    {
                        int ModelCache = Maticsoft.Common.ConfigHelper.GetConfigInt("ModelCache");
                        Maticsoft.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
                    }
                }
                catch { }
            }
            return (lcps.Model.projectinfo)objModel;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<lcps.Model.projectinfo> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<lcps.Model.projectinfo> DataTableToList(DataTable dt)
        {
            List<lcps.Model.projectinfo> modelList = new List<lcps.Model.projectinfo>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                lcps.Model.projectinfo model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new lcps.Model.projectinfo();
                    if (dt.Rows[n]["ID"] != null && dt.Rows[n]["ID"].ToString() != "")
                    {
                        model.ID = int.Parse(dt.Rows[n]["ID"].ToString());
                    }
                    if (dt.Rows[n]["bidid"] != null && dt.Rows[n]["bidid"].ToString() != "")
                    {
                        model.bidid = dt.Rows[n]["bidid"].ToString();
                    }
                    if (dt.Rows[n]["purchaseid"] != null && dt.Rows[n]["purchaseid"].ToString() != "")
                    {
                        model.purchaseid = dt.Rows[n]["purchaseid"].ToString();
                    }
                    if (dt.Rows[n]["usework"] != null && dt.Rows[n]["usework"].ToString() != "")
                    {
                        model.usework = dt.Rows[n]["usework"].ToString();
                    }
                    if (dt.Rows[n]["projectname"] != null && dt.Rows[n]["projectname"].ToString() != "")
                    {
                        model.projectname = dt.Rows[n]["projectname"].ToString();
                    }
                    if (dt.Rows[n]["projecttype"] != null && dt.Rows[n]["projecttype"].ToString() != "")
                    {
                        model.projecttype = dt.Rows[n]["projecttype"].ToString();
                    }
                    if (dt.Rows[n]["supplier"] != null && dt.Rows[n]["supplier"].ToString() != "")
                    {
                        model.supplier = dt.Rows[n]["supplier"].ToString();
                    }
                    if (dt.Rows[n]["materiel"] != null && dt.Rows[n]["materiel"].ToString() != "")
                    {
                        model.materiel = dt.Rows[n]["materiel"].ToString();
                    }
                    if (dt.Rows[n]["unit"] != null && dt.Rows[n]["unit"].ToString() != "")
                    {
                        model.unit = dt.Rows[n]["unit"].ToString();
                    }
                    if (dt.Rows[n]["nums"] != null && dt.Rows[n]["nums"].ToString() != "")
                    {
                        model.nums = int.Parse(dt.Rows[n]["nums"].ToString());
                    }
                    if (dt.Rows[n]["deliverydate"] != null && dt.Rows[n]["deliverydate"].ToString() != "")
                    {
                        model.deliverydate = DateTime.Parse(dt.Rows[n]["deliverydate"].ToString());
                    }
                    if (dt.Rows[n]["arrivaldate"] != null && dt.Rows[n]["arrivaldate"].ToString() != "")
                    {
                        model.arrivaldate = DateTime.Parse(dt.Rows[n]["arrivaldate"].ToString());
                    }
                    if (dt.Rows[n]["workdate"] != null && dt.Rows[n]["workdate"].ToString() != "")
                    {
                        model.workdate = DateTime.Parse(dt.Rows[n]["workdate"].ToString());
                    }
                    if (dt.Rows[n]["drawingplandate"] != null && dt.Rows[n]["drawingplandate"].ToString() != "")
                    {
                        model.drawingplandate = DateTime.Parse(dt.Rows[n]["drawingplandate"].ToString());
                    }
                    if (dt.Rows[n]["drawingstate"] != null && dt.Rows[n]["drawingstate"].ToString() != "")
                    {
                        model.drawingstate = dt.Rows[n]["drawingstate"].ToString();
                    }
                    if (dt.Rows[n]["drawingsubmitdate"] != null && dt.Rows[n]["drawingsubmitdate"].ToString() != "")
                    {
                        model.drawingsubmitdate = DateTime.Parse(dt.Rows[n]["drawingsubmitdate"].ToString());
                    }
                    if (dt.Rows[n]["drawingconfirmdate"] != null && dt.Rows[n]["drawingconfirmdate"].ToString() != "")
                    {
                        model.drawingconfirmdate = DateTime.Parse(dt.Rows[n]["drawingconfirmdate"].ToString());
                    }
                    if (dt.Rows[n]["designstate"] != null && dt.Rows[n]["designstate"].ToString() != "")
                    {
                        model.designstate = dt.Rows[n]["designstate"].ToString();
                    }
                    if (dt.Rows[n]["majormaterielpurchase"] != null && dt.Rows[n]["majormaterielpurchase"].ToString() != "")
                    {
                        model.majormaterielpurchase = dt.Rows[n]["majormaterielpurchase"].ToString();
                    }
                    if (dt.Rows[n]["deviceproductionstate"] != null && dt.Rows[n]["deviceproductionstate"].ToString() != "")
                    {
                        model.deviceproductionstate = dt.Rows[n]["deviceproductionstate"].ToString();
                    }
                    if (dt.Rows[n]["mothstate"] != null && dt.Rows[n]["mothstate"].ToString() != "")
                    {
                        model.mothstate = dt.Rows[n]["mothstate"].ToString();
                    }
                    if (dt.Rows[n]["nextmoth"] != null && dt.Rows[n]["nextmoth"].ToString() != "")
                    {
                        model.nextmoth = dt.Rows[n]["nextmoth"].ToString();
                    }
                    if (dt.Rows[n]["planarrivedate"] != null && dt.Rows[n]["planarrivedate"].ToString() != "")
                    {
                        model.planarrivedate = dt.Rows[n]["planarrivedate"].ToString();
                    }
                    if (dt.Rows[n]["coordinate"] != null && dt.Rows[n]["coordinate"].ToString() != "")
                    {
                        model.coordinate = dt.Rows[n]["coordinate"].ToString();
                    }
                    if (dt.Rows[n]["remark"] != null && dt.Rows[n]["remark"].ToString() != "")
                    {
                        model.remark = dt.Rows[n]["remark"].ToString();
                    }
                    if (dt.Rows[n]["proid"] != null && dt.Rows[n]["proid"].ToString() != "")
                    {
                        model.proid = dt.Rows[n]["proid"].ToString();
                    }
                    if (dt.Rows[n]["realdate"] != null && dt.Rows[n]["realdate"].ToString() != "")
                    {
                        model.realdate = DateTime.Parse(dt.Rows[n]["realdate"].ToString());
                    }
                    if (dt.Rows[n]["receivedname"] != null && dt.Rows[n]["receivedname"].ToString() != "")
                    {
                        model.receivedname = dt.Rows[n]["receivedname"].ToString();
                    }
                    if (dt.Rows[n]["suppliername"] != null && dt.Rows[n]["suppliername"].ToString() != "")
                    {
                        model.suppliername = dt.Rows[n]["suppliername"].ToString();
                    }
                    if (dt.Rows[n]["supplierphone"] != null && dt.Rows[n]["supplierphone"].ToString() != "")
                    {
                        model.supplierphone = dt.Rows[n]["supplierphone"].ToString();
                    }
                    if (dt.Rows[n]["checkstate"] != null && dt.Rows[n]["checkstate"].ToString() != "")
                    {
                        model.checkstate = dt.Rows[n]["checkstate"].ToString();
                    }
                    if (dt.Rows[n]["transactdate"] != null && dt.Rows[n]["transactdate"].ToString() != "")
                    {
                        model.transactdate = DateTime.Parse(dt.Rows[n]["transactdate"].ToString());
                    }
                    if (dt.Rows[n]["agent"] != null && dt.Rows[n]["agent"].ToString() != "")
                    {
                        model.agent = dt.Rows[n]["agent"].ToString();
                    }
                    if (dt.Rows[n]["tableid"] != null && dt.Rows[n]["tableid"].ToString() != "")
                    {
                        model.tableid = int.Parse(dt.Rows[n]["tableid"].ToString());
                    }
                    //办理出入库时间
                    if (dt.Rows[n]["dealStorageDate"] != null && dt.Rows[n]["dealStorageDate"].ToString() != "")
                    {
                        model.dealStorageDate = DateTime.Parse(dt.Rows[n]["dealStorageDate"].ToString());
                    }
                    //是否预警 
                    if (dt.Rows[n]["isWarn"] != null && dt.Rows[n]["isWarn"].ToString() != "")
                    {
                        model.isWarn = int.Parse(dt.Rows[n]["isWarn"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        //{
        //return dal.GetList(PageSize,PageIndex,strWhere);
        //}

        #endregion  Method
	}
}

